cmake_minimum_required(VERSION 2.8)

project(FaceDetector)

set( CMAKE_CXX_STANDARD 11 )
set( CMAKE_CXX_STANDARD_REQUIRED ON )
# set cross-compiled system type, it's better not use the type which cmake cannot recognized.
SET ( CMAKE_SYSTEM_NAME Linux )
SET ( CMAKE_SYSTEM_PROCESSOR x86 )
# if gcc/g++ was installed: 
SET ( CMAKE_C_COMPILER "gcc" )
SET ( CMAKE_CXX_COMPILER "g++" )

# set searching rules
SET ( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )
SET ( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
SET ( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )

# set ${CMAKE_C_FLAGS} and ${CMAKE_CXX_FLAGS}flag
SET ( CMAKE_CXX_FLAGS "-O3 -Wall -std=c++11 ${CMAKE_CXX_FLAGS}" )

#find_package(ncnn CONFIG REQUIRED)
find_package(pybind11 REQUIRED)


if(True)
    find_package(OpenMP)
    if(NOT TARGET OpenMP::OpenMP_CXX AND (OpenMP_CXX_FOUND OR OPENMP_FOUND))
        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
        set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
    endif()
endif()

include_directories(
                    ${CMAKE_CURRENT_SOURCE_DIR}/ncnn/include/ncnn)

link_directories(
                 ${CMAKE_CURRENT_SOURCE_DIR}/ncnn/lib)
set(OpenCV_LIBS opencv_core 
                opencv_highgui 
                opencv_imgproc 
                opencv_imgcodecs 
                opencv_videoio)

#set(SRC
#        main.cpp
#        FaceDetector.h
#        FaceDetector.cpp
#        )

set(SRC
        main.cpp
        FaceDetector.h
        FaceDetector.cpp
        )

#add_library(FaceDetector ${SRC})
add_executable(FaceDetector ${SRC})

if(OpenMP_CXX_FOUND)
    message("Building with OpenMP")
    target_link_libraries(FaceDetector PUBLIC OpenMP::OpenMP_CXX ncnn ${OpenCV_LIBS})
else()
    target_link_libraries(FaceDetector ncnn ${OpenCV_LIBS})
endif()
